package com.bw.shinelon.yuekaoa;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RadioGroup;

import com.nostra13.universalimageloader.core.ImageLoader;

public class Main2Activity extends AppCompatActivity implements View.OnClickListener {

    private Button tv1;
    private Button tv2;
    private Button btn1;
    private Button btn2;
    private Button btn3;
    private RadioGroup RG;
    private LinearLayout activity_main2;
    private Fragment01 fragment01;
    private Fragment02 fragment02;
    private Fragment03 fragment03;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        initView();

        fragment01=new Fragment01();
        fragment02=new Fragment02();
        fragment03=new Fragment03();

        getSupportFragmentManager().beginTransaction().add(R.id.frame, fragment03).commit();
        getSupportFragmentManager().beginTransaction().add(R.id.frame, fragment02).commit();
        getSupportFragmentManager().beginTransaction().add(R.id.frame, fragment01).commit();
        getSupportFragmentManager().beginTransaction().show(fragment01).hide(fragment02).hide(fragment03).commit();
    }

    private void initView() {
        tv1 = (Button) findViewById(R.id.tv1);
        tv2 = (Button) findViewById(R.id.tv2);
        btn1 = (Button) findViewById(R.id.btn1);
        btn2 = (Button) findViewById(R.id.btn2);
        btn3 = (Button) findViewById(R.id.btn3);
        RG = (RadioGroup) findViewById(R.id.RG);
        activity_main2 = (LinearLayout) findViewById(R.id.activity_main2);

        tv1.setOnClickListener(this);
        tv2.setOnClickListener(this);
        btn1.setOnClickListener(this);
        btn2.setOnClickListener(this);
        btn3.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tv1:

                break;
            case R.id.tv2:
                //初始化
                ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(Main2Activity.this).build();
                //创建Imageloader 对象
                ImageLoader imageLoader = ImageLoader.getInstance();
                //设置初始化
                imageLoader.init(config);
                //清理缓存
                imageLoader.getInstance().clearDiskCache();
                imageLoader.getInstance().clearMemoryCache();
                break;
            case R.id.btn1:
                getSupportFragmentManager().beginTransaction().show(fragment01).hide(fragment02).hide(fragment03).commit();
                break;
            case R.id.btn2:
                getSupportFragmentManager().beginTransaction().show(fragment02).hide(fragment01).hide(fragment03).commit();
                break;
            case R.id.btn3:
                getSupportFragmentManager().beginTransaction().show(fragment03).hide(fragment02).hide(fragment01).commit();
                break;
        }
    }
}
